from django.conf.urls.defaults import *
from django.conf import settings
from django.contrib import admin
admin.autodiscover()

from django.contrib.staticfiles.urls import staticfiles_urlpatterns


urlpatterns = patterns('',
    # Example:
    (r'^', include('ask.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    (r'^admin/', include(admin.site.urls)),
    (r'^accounts/', include('registration.backends.simple.urls')),
    (r'^rest/', include('common.rest_urls')),
)

urlpatterns += staticfiles_urlpatterns()


from voting.views import vote_on_object
from common.views import my_vote_on_object
vote_on_object = my_vote_on_object(vote_on_object)
vote_dict = {
    'allow_xmlhttprequest': True,
    'template_name' : 'vote_confirm.html',
}
urlpatterns += patterns('',
    url(r'^(?P<app>ask)/(?P<model>question|answer)/(?P<object_id>\d+)/(?P<direction>up|down|clear)vote/$',
        view=vote_on_object,
        name='vote',
        kwargs=vote_dict
    ),
)

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes': True} ),
    )
